﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace StudentManagement.Models
{
    public class StudentRepository: IStudentRepository
    {
        private readonly List<Student> _studentList;

        public StudentRepository()
        {
            _studentList = new List<Student>
            {
                new Student {Id = 1, Name = "张三", ClassName = ClassNameEnum.FirstGrade, Email = "Tony-zhang@52abp.com"},
                new Student {Id = 2, Name = "李四", ClassName = ClassNameEnum.SecondGrade, Email = "lisi@52abp.com"},
                new Student {Id = 3, Name = "王二麻子", ClassName = ClassNameEnum.GradeThree, Email = "wang@52abp.com"}
            };
        }

        public IEnumerable<Student> GetAllStudents()
        {
            return _studentList;
        }

        public Student GetStudent(int id)
        {
           return _studentList.FirstOrDefault(s=>s.Id==id);
        }

        public void Save(Student student)
        {
            //写逻辑实现保存学生信息
            throw new NotImplementedException();
        }


        public Student Add(Student student)
        {
            student.Id = _studentList.Max(s=>s.Id)+1;
            _studentList.Add(student);
            return student;
        }

        public Student Update(Student student)
        {
            throw new NotImplementedException();
        }

        public Student Delete(int id)
        {
            throw new NotImplementedException();
        }
    }
}
